#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>

/*   32-126  95 chars */
#define SIGN_SIZE 95
/*int lengthOfLongestSubstring(char* s) {
    int sign[SIGN_SIZE]={ [0 ... 9]=-1 };
    int r=0,maxL=0,idx,start=0;
    for(int i=0; s[i]!='\0'; i++) {
        idx=s[i]-32;
        //if( sign[ idx ] == -1 ){
        if( sign[ idx ] < start ){
            sign[ idx ] = i;
            maxL++;
        }else{
            maxL = i - sign[ idx ];
            start = sign[ idx ] + 1;
            sign[ idx ] = i;
        }
        if( maxL > r )
            r=maxL;
        printf("r:%d start:%d maxL:%d\n",r,start,maxL);
    }
    return r;
}*/
/*
int max(int a,int b){
    return a>b?a:b;
}
int lengthOfLongestSubstring(char* s) {
    int r=0,idx,left=0;
    bool sign[SIGN_SIZE]={ [0 ... 94]=false };
    for(int right=0; s[right]; right++) {
        idx= s[ right ] - 32;
        if( sign[ idx ] ){
            int t;
            while( sign[ idx ] ){
                t= s[ left++ ] - 32;
                sign[ t ] = false;
            }
        }
        sign[ idx ]=true;
        r=max(r,right-left+1);
    }
    return r;
}
int main(){
    char test[]="abadc";
    printf("%d\n",lengthOfLongestSubstring(test));
    return 0;
}*/


#define SIGN_SIZE 95
#define Char(x) ( (x) - 32 )
int lengthOfLongestSubstring(char* s) {
    int last_pos[SIGN_SIZE]={ [0 ... (SIGN_SIZE)-1] = -1 };
    int r=0,maxL=0,idx,start=0;
    for(int i=0; s[i]!='\0'; i++) {
        //idx=s[i]-32;
        if( last_pos[ Char(s[i]) ] < start ){
            maxL++;
        }else{
            maxL = i - last_pos[ Char(s[i]) ];
            start = last_pos[ Char(s[i]) ] + 1;
        }
        last_pos[ Char(s[i]) ] = i;
        if( maxL > r )
            r=maxL;
    }
    return r;
}
